import java.security.Principal;
import java.util.Scanner;

public class Test7 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a=sc.nextInt();
        int b=a/1000;
        int c=a/100%10;
        int d=a/10%10;
        int e=a%10;
        int num=e*1000+d*100+c*10+b;
        System.out.print(num);
    }
}
